home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
EDITOR
/
AMAC44.ARJ
/
SM.QM
< prev
next >
Wrap
Text File
|
1992-05-27
|
17KB
|
380 lines
* SM.QM, ver P
* Search From Command Line With MaxFind
* 5/30/92
* Written by Tom Hogshead
*
* @6 Search From Command Line, Load Files w/Search Text (Must Use SM.BAT)
*
* f4 Finds search text in file after loading
* f5 PrevFile
* f6 NextFile
*
* @h Jump To Macro or Index Item
*
* Description
* Syntax
* Mode
* Required
* Options - MaxFind
* Note
* Examples
* Index use with @h
* PCED synonymns to search from a file list
* Other macros:
* Environment Variables - See SRCHxx.QM for discussion
* Required Program Files
* CAUTION <<<<<
* Version history
*
*--eoi
* (DESCRIPTION)
* --------------
* SM.QM are QEdit macros to search files containing a search string using
* MaxFind. Files are searched, found, and loaded for editing or viewing.
* The search string, file names, and other input or search options may be
* specified at the command line or entered at the option query prompt.
* "Fuzzy", "and/or", and "sliding window" text searches can be done.
*
* To run, type "sm" <enter>, and answer the prompts. Press F4 to
* view the search string in each file after finding. Alternatively,
* parameters may be specified at the command line.
* 1) SYNTAX: SM.BAT %1 %2 %3
* ┌──────────┘ │ └───────────┐
* (Mode) %1 %2 %3
* Search Text File Name Option
* ---------------- ------------- ---------- -------
* a) Query <------- all inputs at prompts ------->
* b) Partial Query Search Text [ ] [ ]
* c) Partial Query Search Text [ ] default
* d) Command line Search Text File Name default
* e) All command line Search Text File Name [ ]
*
* where: %1 - Search Text
* %2 - File Name, wild cards OK
* %3 - MAXFIND options entered without minus
* [ ] - entered at query prompt
* 2) Requires MAXFIND MF.EXE and INPUT.COM
* 3) File Name wild cards OK.
* 4) MAXFIND options can be input at option prompt or %3, default option "ltn"
* 5) Set environment variable OPT=off to bypass MAXFIND option query prompt
*
* MAXFIND (OPTIONS):
*
* MaxFind. Version 2.3 Copyright 1988,90 by Stan Peters
* Shareware, $15. Box 2028, Fairfield, Iowa 94306
* Usage: mf [-options] string [string].... filename [-options]
* Filename may contain ? and *, it may have a path prefix
* You may have 1 to 15 strings.
* A tilde (~) in a string matches any character.
* Options must start with a '- ', they may be first and/or last.
* Searching options:
* a - 'and', all must be present. f - "fuzzy", approximate spelling.
* c - case sensitive search. w - match only if a word.
* d - Span entire document, if necessary.
* Output options:
* l - show line numbers. (*) t - to screen and > file. (*)
* m - stop after first match. (*) u - Unix (grep) style output.(*)
* n - no pause each 24 lines. (*)
* Input options:
* b - also search binary files. s - also include subdirectorys
* h - strip hi (8) bits.
* AND searches using "sliding windows":
* 2 - 15 Window size (number of lines) for searching and displaying
*
* afcwdbsh/ - OK with SM
*
* A / indicates an OR within an AND, use // to find / .
* Example: Find Tom or Bob Jones from Texas in my address file
* Enter: "mf tom/bob jones texas address.fil -a4"
*
* (*) - do not use with sm.bat, "ntl" are default options with sm.bat
* (NOTE)
* -------
* - @6 must be the first macro in this file to be used with sm.bat.
* - To use this macro in any directory, change /Esm.mac and
* /Lsm.mac in sm.bat to the location of sm.mac, eg change to
* /Ee:\up\sm.mac.
* - Enter other search or input options as %3 or at the option,
* prompt, eg "c" for case sensitive search without the minus.
* - Search is case insensitive unless option "c" is specified.
* - If no files are found containing the search text, a message
* "No text found" is displayed.
* - Macro will stop before completion if any line containing the
* search text also contains "g>". Macro cannot search for "g>".
* - This macro can be quite "noisy" if beeps are set on with
* QCONFIG, especially if there are many lines containing
* search text. We use "Find" to check each line of the output
* to determine whether it is a file name or found text. File
* names are not quite as "noisy". Testing this macro has forced
* me to set QEdit beeps "off"!
* - A minimum of of 55 bytes free environment space is needed to
* search for a 10 character string with 12 character file spec
* and 1 character option. I suggest you have at least a 100
* bytes free to be safe. Since the free environment space is
* considerably reduced when "shelling to DOS", sm.bat may not
* work properly when "shelled" from another program.
* - MaxFind writes to disk at least once for every file it
* searches. Therefore, for faster macro operation, replace c:\
* in sm.bat and sm.qm with your ram drive.
* (EXAMPLES)
* -----------
* a) Example: Load all files with extension "bat" or "tst"
* containing "aaa" and "bbb" in each file.
* (Must be run from input mode because of %1 %2 %3 defs.)
* Enter: "sm" <enter>, and at the query prompts enter...
* Search text =aaa bbb
* File name(s) =*.??t
* Option(s) =
*
* b) Example: Load all files with extension "tst" containing "ccc"
* Enter: "sm ccc *.tst" <enter>
* c) Example: Load all files containing "ddd" and "eee" only
* within a 2 line window in each file, with extension
* "tst".
* (Must be run from input mode because of %1 %2 %3 defs.)
* Enter: "sm" <enter>, and at the query prompts enter...
* Search text =ddd eee
* File name(s) =*.tst
* Option(s) =a2
* (sm.tst is included to test above examples)
* (INDEX) USE
* -----------
* To locate a macro or item in this file, press @h, place the cursor
* line on the desired item in the Index above, and press <enter>.
* See BOOKxx.QM for more details.
* (PCED) Synonymns To Search From A File List
* --------------------------------------------
* MaxFind does not have the option of searching from a file list.
* However PCED by Chris Dunford with the following synonyms using the
* "@@file list" option will search from the file list "sm.lst".
*
* rem PCED synonyms for MaxFind Search, Syntax: SMC1 [search text]
*
* SYN smc1 'cef^cancel &A^delc^mfc &A^qec^cen'
* SYN cancel 'if "&A" == "" CED CANCEL notxt'
* SYN notxt 'echo No search text, Syntax: SMC1 [search text]^cen'
* SYN cef 'CED ECHO OFF^echo off'
* SYN delc 'if exist c:\! del c:\!'
* SYN cen 'echo on^CED ECHO ON'
* SYN mfc 'mf.exe -ntl &A @@sm.lst>>c:\!'
* SYN qec 'q.exe c:\! /Esm.mac /Lsm.mac'
* rem SYN mfc 'mf.exe -ntl &A @@e:\up\sm.lst>>c:\!'
* rem SYN qec 'q.exe c:\! /Ee:\up\sm.mac /Le:\up\sm.mac'
* NOTE: Change "e:\up\" to the directory where sm.mac and sm.lst reside.
* "REM" lines are my setup.
*
* You must have PCED v2.00 or later with the Filelist progam FL.EXE
* loaded. These synonyms are in sm.sym and can be loaded with SM_SYN.bat
* File list sm.lst is only one line "*.tst" for testing. To test,
* type "smc1 aaa" <enter> after loading these synonyms.
* (OTHER) MACROS
* ------------------
* See SRCxxx.QM in AMACxx.Zip for search and search/replace macros using
* Chris Dunford's excellent FGREP.COM.com.
* >>>>>>> (CAUTION) <<<<<<<<
*
* Letters "S~~" and "R~~" must NOT occur in any other Dos environment
* variable name or value.
*
* (ENVIRONMENT) Variables - See SRCHxx.QM for discussion
* (REQUIRED) PROGRAM FILES
* --------------------------
* You──MUST──have the exectable program files in AMAC-PRG.ZIP to run
* some of these macros. AMAC-PRG.ZIP can be found on the following BBS's:
*
* SemWare
* Exec-PC
*
* It can not be found on CompuServe since many of the programs are
* Copyrighted. All program files are ShareWare, and inclusion in
* AMAC-PRG.ZIP is not prohibited in their documentation.
*
* MAXFND23.ZIP and INPUT.ZIP are the only files necessary to run SM.BAT.
*
* INPUT can be found on Exec-PC as INPUT.ZIP. MAXFIND v2.3 can be found
* on CompuServe IBMSYS Lib 3 as MAXFND.ZIP and on EXec-PC as
* MAXFND23.ZIP
*
* AMAC-PRG.ZIP contains:
* ----------------------
* Name Length Method SF Size now Mod Date
* ============ ======== ======== ==== ======== =========
* INPUT.ZIP 3097 Stored 0 3097 07 May 86
* MAXFND23.ZIP 24247 Stored 0 24247 26 Apr 90
* RJ.ZIP 9965 Stored 0 9965 01 Dec 90
* FGREP172.ZIP 12513 Stored 0 12513 19 May 90
* DX211.ZIP 100895 Stored 0 100895 17 Mar 89
* AMAC-PRG.INF 3138 Imploded 67 1014 23 Apr 91
* ============ ======== ======== ==== ======== =========
* *total 6 153855 ZIP 1.10 0% 152329 23 Apr 91
*
* I thank the authors for these excellent programs.
*
* ----------------------------------------------------------------------
* @(6) - Srch ONLY from command line, loads files w/sm.bat, no replace
* -------------------- uses MaxFind mf.exe -----------------------------
* >>> MUST BE THE FIRST MACRO IN THIS FILE TO BE USED WITH SM.BAT <<<
*
@6 macrobegin
altwordset * For all file names
begfile * Just in case!
* ----------------- delete MaxFind Copyright header -----------------*
header:
find "xfind C" return return * Find MaxFind header
jfalse end_header
delline * Delete it until no more
jump header
end_header:
* --------- delete "Hex file skipped" message and file name ---------*
begfile * Back to tof
hex:
find "Hex file s" return return * Find "Hex file skipped" msg
jfalse end_hex
delline * Delete it until no more
cursorup * Move up to hex name
delline * Delete it
jump hex * And do until done
end_hex:
begfile * Back to tof
* ------------------ delete file names with no text ------------------*
cleanup:
begline * Position for find
unmarkblock
markline markline * Mark line to check if name
find "g>" return "L" return * Check if name
jtrue name * If name, check if next line
* is also name
cursordown *ELSE move down to next line
jfalse end_cleanup * If can't move down, at eof
jump cleanup * Check this line if name
name:
cursordown * Is a file, move down to next
* line
jfalse delete * If can't move down, at eof
* and it's a name, go delete it
cursorright *ELSE put cursor on >
unmarkblock *
markcolumn * Begin mark
cursorleft * Move left one space
markcolumn * Mark column to check for "g>"
cursorleft * Move to "n" in "Searching"
find "g>" return "L" return * Is line a name?
jfalse cleanup * If not a name, go to cleanup
cursorup *ELSE must be text, move back
* up to where we were
jfalse end_cleanup * If can't move up, at tof
delline *ELSE Delete name with no text
jump cleanup
delete:
delline * Delete last line if name
end_cleanup:
* -------------------- load file names with text --------------------*
endfile * Start to load at eof
load:
begline * Position for find
find "g>" return "B" return * Find line with file name
jfalse text * No more file names? Move up
wordright *wordright wordright * Move to file name
unmarkblock * Clear last mark
markcolumn * And begin mark
endline * Get all name in block
copy * Copy file name to scrap
EditFile * Get ready to load
CurrentFilename " " * To force return *here*
Paste Return * Paste file name & do it!
text:
cursorup * Go to next line
jfalse end_load * No more file names? End load
jump load *ELSE more files to load
end_load:
* --------------------- "No found text" message ---------------------*
cursordown cursorup * Test if any search text found
jtrue find_set * If found, move on
"No found text " *ELSE no find, display this
jump end * End macro if no found text
find_set:
* -------------------- initialize find for search --------------------*
editfile "c:\$" return * Load tempfile
find "S~~" return return ** Find S~~ in SET output
find "=" return return * Move to =
cursorright * Move first character
markcharacter * Mark it
endline * Move to end of text
copy * Copy search text to scrap
killfile quit * Kill/quit temp for next time
Find paste return Escape * Initialize find for F4
* ------------------------------ reset ------------------------------*
end: defaultwordset * Reset
*
* 233 bytes Wed 04-17-1991 16:35:04
* 216 bytes Wed 04-24-1991 14:18:01 moved DOS "set>c:$" to SM.BAT
* replace R~~ with S~~
* 221 bytes Tue 04-30-1991 22:28:02 changed initialize find routine
*
* (f4) Finds search text in file after loading
f4 repeatfind
*
* (f5) prevfile
*
f5 prevfile
*
* (f6) nextfile
f6 nextfile
*
* ----------------------------------------------------------------------
* @(h) Finds first word on cursor line marked in document below
* ----------------------------------------------------------------------
* Press @ and h at the same time. Cursor down to desired line in Index.
* Press <enter> to locate the desired item from the Index. See
* Bookxx.Qm in AMACxx.Zip for more discussion.
*
@h macrobegin
begfile
unmarkblock
markline markline
pause
wordright
markword
copy
endpara
find "(" paste ")" return return
begline
*
* 22 bytes Tue 04-09-1991 16:23:53
* (Version) History
* ------------------
* M - Changed SRCHxx version from 2.9 to 3.0. 8/6/91
* N - Changed SM-SYN.BAT name to SM_SYN.BAT. 8/26/91
* O - Modified documentation in this file. 5/22/92
* - In Amac43.zip. 5/27/92
* P - Added ( ) to Index line 1 for bok001.qm macros. 5/30/92
*
*
*
*--eof